﻿#pragma once

#include "lp_conf.h"

typedef enum LPHashType{
    LPHASH_AP = 0,
    LPHASH_RS,
    LPHASH_JS,
    LPHASH_PJW,
    LPHASH_ELF,
    LPHASH_BKDR,
    LPHASH_SDBM,
    LPHASH_DJB,
    LPHASH_DEK,
}LPHashType;

typedef struct LPMap LPMap;
typedef int (* LPMapKeyCompare)
    (const void * k1, size_t sz1, const void * k2, size_t sz2);
typedef uint32_t (* LPMapKeyHash)(const char * k, size_t sz);


LP_API uint32_t
lpHash(const char * k, size_t sz, LPHashType type);

LP_API uint32_t
lpMapHash(const char * k, size_t sz);

LP_API LPMap *
lpNewMap(uint32_t cap);

LP_API void
lpFreeMap(LPMap * map);

LP_API void
lpExpandMap(LPMap * map, uint32_t cap);

LP_API void
lpPutMap (LPMap * map,
        const void * k, size_t ksz, const void * v);

LP_API int
lpDelMap (LPMap * map, const void * k, size_t ksz);


LP_API int
lpFindInMap (LPMap * map,
        const void * k, size_t ksz, const void ** v);

LP_API size_t
lpCountMap (LPMap * map);

LP_API void
lpBeginMap (LPMap * map);

LP_API int
lpNextMap (LPMap * map,
    const void ** k, size_t * ksz, const void ** v);

